import { findHeadCategory } from '@/api/home'
export default {
  namespaced: true,
  state: () => {
    return { list: [] }
  },
  mutations: {
    // 设置state中的list
    setList (state, headCategory) {
      state.list = headCategory
    }
  },
  actions: {
    async asyncSetList (context) {
      // 1. 发请求
      const res = await findHeadCategory()
      console.log(res.result)
      // 2. 调用mutation保存数据
      // 在action中调用mutation
      context.commit('setList', res.result)
    }
  }
}
